//timer implementation
//wssccc ROBOT SDK 1.1

//2010-4-15

/*
 __  __  __    ____    ____    ___    ___    ___   
/\ \/\ \/\ \  /',__\  /',__\  /'___\ /'___\ /'___\ 
\ \ \_/ \_/ \/\__, `\/\__, `\/\ \__//\ \__//\ \__/ 
 \ \___x___/'\/\____/\/\____/\ \____\ \____\ \____\
  \/__//__/   \/___/  \/___/  \/____/\/____/\/____/
  
MAIL : wssccc@gmail.com                                                    
  */

//ICC-AVR application builder : 2010/4/15 16:39:35
// Target : m48
// Crystal: 8.0000Mhz

#include <iom48v.h>
#include <macros.h>


//TIMER1 initialize - prescale:256
// WGM: 0) Normal, TOP=0xFFFF
// desired value: 5Hz
// actual value:  5.000Hz (0.0%)
void timer1_init(void)
{
 TCCR1B = 0x00; //stop
 TCNT1H = 0xE7; //setup
 TCNT1L = 0x96;
 OCR1AH = 0x18;
 OCR1AL = 0x6A;
 OCR1BH = 0x18;
 OCR1BL = 0x6A;
 ICR1H  = 0x18;
 ICR1L  = 0x6A;
 TCCR1A = 0x00;
 TCCR1B = 0x04; //start Timer
}

//ICC-AVR application builder : 2010/4/15 17:40:48
// Target : m48
// Crystal: 8.0000Mhz



#pragma interrupt_handler timer1_ovf_isr:14
void timer1_ovf_isr(void)
{
 //TIMER1 has overflowed
 TCNT1H = 0xE7; //reload counter high value
 TCNT1L = 0x96; //reload counter low value
 
 //add timer_event handler code
 
 
 
}
